<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    29. Divide Two Integers
   </h1>
   <p>
    Given two integers
    <code>
     dividend
    </code>
    and
    <code>
     divisor
    </code>
    , divide two integers without using multiplication, division and mod operator.
   </p>
   <p>
    Return the quotient after dividing
    <code>
     dividend
    </code>
    by
    <code>
     divisor
    </code>
    .
   </p>
   <p>
    The integer division should truncate toward zero.
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> dividend = 10, divisor = 3
<strong>Output:</strong> 3</pre>
   <p>
    <strong>
     Example 2:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> dividend = 7, divisor = -3
<strong>Output:</strong> -2</pre>
   <p>
    <strong>
     Note:
    </strong>
   </p>
   <ul>
    <li>
     Both dividend and divisor&nbsp;will be&nbsp;32-bit&nbsp;signed integers.
    </li>
    <li>
     The divisor will never be 0.
    </li>
    <li>
     Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [&minus;2
     <sup>
      31
     </sup>
     , &nbsp;2
     <sup>
      31
     </sup>
     &minus; 1]. For the purpose of this problem, assume that your function returns 2
     <sup>
      31
     </sup>
     &minus; 1 when the division result&nbsp;overflows.
    </li>
   </ul>
  </div>
  <div>
   <h1 class="question_title">
    29. 两数相除
   </h1>
   <p>
    给定两个整数，被除数&nbsp;
    <code>
     dividend
    </code>
    &nbsp;和除数&nbsp;
    <code>
     divisor
    </code>
    。将两数相除，要求不使用乘法、除法和 mod 运算符。
   </p>
   <p>
    返回被除数&nbsp;
    <code>
     dividend
    </code>
    &nbsp;除以除数&nbsp;
    <code>
     divisor
    </code>
    &nbsp;得到的商。
   </p>
   <p>
    <strong>
     示例&nbsp;1:
    </strong>
   </p>
   <pre><strong>输入:</strong> dividend = 10, divisor = 3
<strong>输出:</strong> 3</pre>
   <p>
    <strong>
     示例&nbsp;2:
    </strong>
   </p>
   <pre><strong>输入:</strong> dividend = 7, divisor = -3
<strong>输出:</strong> -2</pre>
   <p>
    <strong>
     说明:
    </strong>
   </p>
   <ul>
    <li>
     被除数和除数均为 32 位有符号整数。
    </li>
    <li>
     除数不为&nbsp;0。
    </li>
    <li>
     假设我们的环境只能存储 32 位有符号整数，其数值范围是 [&minus;2
     <sup>
      31
     </sup>
     ,&nbsp; 2
     <sup>
      31&nbsp;
     </sup>
     &minus; 1]。本题中，如果除法结果溢出，则返回 2
     <sup>
      31&nbsp;
     </sup>
     &minus; 1。
    </li>
   </ul>
  </div>
 </body>
</html>